from wcs.libs.players import players
from wcs.libs.items import items

itemName = 'Life Preserver'
item = items.addItem(itemName)
item.setGroup("powerup")
item.setCost(5000)
item.setDescription("A healing light heals you 50 health and 100 armor.")
item.aliveToUse = True
item.appendToUser = False

def wcs_item_bought(event_var):
    """
    Execited when a player buys an item, if the item bought was this item then
    healt the user for the given amount.
    """
    userid = event_var["userid"]
    player = players[userid]
    if event_var['item'] == itemName:
        player.heal(50)
        player.armorAdd(100)